﻿using Galaxy.ModuleInterface;
using Galaxy.ModuleInterface.Messages;

namespace Galaxy.Portal
{
    /// <summary>Модуль портала</summary>
    public abstract class GalaxyPortalModule : GalaxyModule, IPortal
    {
        /* -------------------------------------------------------------------- */

        /// <summary>Порт</summary>
        private int f_Port = 4500;

        /* -------------------------------------------------------------------- */

        /// <summary>Порт</summary>
        public int Port { get { return f_Port; } set { f_Port = value; } }

        /// <summary>Имя портала</summary>
        string IPortal.Name
        {
            get { return Name + ":" + Port; }
            set
            {
                Name = value.Substring(0, value.LastIndexOf(':'));
                Port = int.Parse(value.Substring(value.LastIndexOf(':') + 1));
            }
        }

        /* -------------------------------------------------------------------- */

        /// <summary>Инициализация нового портала</summary>
        protected GalaxyPortalModule() : base("Портал") { }

        /// <summary>Инициализация нового портала</summary>
        /// <param name="Name">Имя портала</param>
        protected GalaxyPortalModule(string Name) : base(Name) { }

        /* -------------------------------------------------------------------- */

        public abstract void SendMessage(IGalaxyModuleMessage Message);

    }
}
